

const { ccclass, property } = cc._decorator;

@ccclass
export default class mapCtl extends cc.Component {

    @property(cc.Graphics)
    mapGraphics: cc.Graphics = null;
 

    blockLen: number = 50           //格子的宽
    // onLoad () {}

    start() {
        this.drawMap();
    }

    // update (dt) {}

    drawMap() {
        this.mapGraphics.lineWidth = 3;
        this.mapGraphics.strokeColor = cc.Color.GRAY;
        this.mapGraphics.moveTo(0, 0)
        this.mapGraphics.lineTo(0, 2000)
        this.mapGraphics.moveTo(0, 0)
        this.mapGraphics.lineTo(2000, 0)
        for (let i = 0; i < 100; i++) {
            this.mapGraphics.moveTo(this.blockLen * (i + 1), 0)
            this.mapGraphics.lineTo(this.blockLen * (i + 1), 2000)
            this.mapGraphics.moveTo(0, this.blockLen * (i + 1))
            this.mapGraphics.lineTo(2000, this.blockLen * (i + 1))
        }
        this.mapGraphics.stroke();
    }

    drawCube(pos: cc.Vec2, color: cc.Color) {
        this.mapGraphics.rect(pos.x * 50, pos.y * 50, 50, 50);
        this.mapGraphics.fillColor = color;
        this.mapGraphics.fill();
    }

   
}
